<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
       img {
        width: 800px;
        height: 600px;
        /* background-color: red; */
       }

    </style>
</head>
<body>
    <div>
         <img src="../images/1.jpg" alt="老人">
    </div>
    <script>
        //1.随机函数：
        // Math.floor(Math.random()*(m-n+1))+n  
        function getRandom (n,m){
            return Math.floor(Math.random()*(m-n+1))+n
        }  
        //2.获取图片对象
        const img = document.querySelector('img')
        const random = getRandom(1,10)
        // 修改，对象.属性 = 值   模板字符串
        img.src = `../images/${random}.jpg`
        console.log(random)
        
        // img.title = '可爱的孩子'
    </script>
</body>
</html>